<!DOCTYPE html>
<html>
    <head>
        <meta charset="utf-8">
        <title>2.4.3Arrauy.of()</title>
    </head>
    <body>
        <script>
            //【例2.26Array构造函数的问题】
            let a=Array();//[]
            let b=Array(3);//[空属性*3]
            let c=Array(3,11,8);//[3,11,8]

            console.log(a);//Array[0]
            console.log(b);//Array[3]
            console.log(c);//Array[3]
            //Array()只有当参数个数不少于2个时,才会返回由参数组成的新数组
            //参数只有一个正整数时，实际上时指定数组的长度

            //【例2.27使用Adrray.of方法构造数组】
            let a2=Array.of()//[]
            let b2=Array.of(undefined)//[undefined]
            let c2=Array.of(3)//[3]
            let d2=Array.of(1,2,3)//[1,2,3]

            console.log(a2);
            console.log(b2);
            console.log(c2);
            console.log(d2);
            //Array.of如果没有参数，就会返回一个空数组
        </script>
    </body>
</html>